package com.tao.controller.webpageController;

import com.tao.context.UserContext;
import com.tao.result.Result;
import com.tao.service.CommonService;
import com.tao.utils.ALiOSSUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;



@RestController
@Slf4j
@RequestMapping("/webPage/common")
public class CommonController {
    @Autowired ALiOSSUtil aLiOSSUtil;
    @Autowired
    CommonService commonService;
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws Exception {
        log.info("上传的文件为：{}",file);
        return Result.success(aLiOSSUtil.upload(file));
    }

    @GetMapping("/menu")
    public Result getMenu(){
        return Result.success(commonService.getMenu(UserContext.getThreadUserRoleId()));
    }
}
